home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / System 7.0 Samples / DTS.Utilities / Utilities.p < prev    next >
Encoding:
Text File  |  1991-02-14  |  22.6 KB  |  513 lines  |  [TEXT/MPS ]

  1.  
  2.  
  3. {-------------------------------------------------------------------------------------------
  4. #
  5. #    Apple Macintosh Developer Technical Support
  6. #
  7. #    Collection of Utilities for DTS Sample code
  8. #
  9. #    Program:    Utilities.p.o
  10. #    File:        Utilities.p -    Pascal Interface
  11. #
  12. #    Copyright © 1988-1990 Apple Computer, Inc.
  13. #    All rights reserved.
  14. #
  15. -------------------------------------------------------------------------------------------}
  16. {[j=20/53/1$] Pasmat Options}
  17.  
  18. UNIT Utilities;
  19.  
  20.     INTERFACE
  21.  
  22.         USES
  23.             { Type 1 }
  24.             Types, QuickDraw,
  25.  
  26.             { Type 2 }
  27.             Controls, Events, FixMath, Fonts, Memory, Menus, OSUtils, Resources, SegLoad,
  28.             TextEdit, ToolUtils, Traps, SysEqu,
  29. {$IFC MPW32}
  30.             {$U $$Shell(PInterfaces)GestaltEqu} GestaltEqu, { Use standard interface }
  31.             {$U $$Shell(PInterfaces)Folders} Folders,         { Use standard interface }
  32. {$ELSEC}
  33.             GestaltEqu,        { Use the one in the Utilities directory }
  34.             Folders,        { Use the one in the Utilities directory }
  35. {$ENDC}
  36.  
  37.             { Type 3 }
  38.             Desk, Files, OSEvents, Script, Windows,
  39.  
  40.             { Type 4 }
  41.             Dialogs,
  42.  
  43.             { Type 5 }
  44.             Packages;
  45.  
  46.         CONST
  47.             kUseCreatorString    = - 1;                { Pass this to StandardAbout if you would
  48.                                                      like the string stored in your creator
  49.                                                      resource to appear in the about box. }
  50.             kUseRealAppName     = - 2;                { Pass this to StandardAbout if you would
  51.                                                      like the name of your application to
  52.                                                      appear in the about box. }
  53.  
  54.             rUtilErrorAlert     = 256;                { dlg ID used in ErrorAlert }
  55.             rUtilErrorMessageAlert = 257;            { dlg ID used in ErrorAlertMessage }
  56.             rStdAboutAlert         = 258;                { dlg ID used for About box. }
  57.  
  58.             rUtilStrings        = 256;                { STR# resource we use for errors. }
  59.             eStandardErr        = 1;                { Generic "An error occured" string. }
  60.             eNoMenuBar            = 2;                { "No 'MBAR' resource was found." }
  61.  
  62.             kButtonFrameSize    = 3;                { button frame’s pen size }
  63.             kButtonFrameInset    = - 4;                { inset rectangle adjustment around
  64.                                                      button }
  65.             kOSEvent            = app4Evt;            { event used by MultiFinder }
  66.             kSuspendResumeMessage = 1;                { high byte of suspend/resume event
  67.                                                      message }
  68.             kResumeMask         = 1;                { bit of message field for resume vs.
  69.                                                      suspend }
  70.             kMouseMovedMessage    = $FA;                { high byte of mouse-moved event message }
  71.             kNoEvents            = 0;                { no events mask }
  72.  
  73.             kExtremeNeg         = - 32768;            { kExtremeNeg and kExtremePos are used to
  74.                                                      set up wide open rectangles and
  75.                                                      regions. }
  76.             kExtremePos         = 32767 - 1;        { required for old region bug }
  77.  
  78.             kOffscreenLoc        = $4000;
  79.  
  80.             kDITop                = $0050;            { kDITop and kDILeft are used to locate
  81.                                                      the Disk Initialization dialogs. }
  82.             kDILeft             = $0070;
  83.  
  84.             kControlInvisible    = 0;
  85.             kControlVisible     = $FF;                {kControlInvisible is used to 'turn off'
  86.                                                      controls (i.e., cause the control not to be
  87.                                                      redrawn as a result of some Control Manager
  88.                                                      call such as SetCtlValue) by being put into
  89.                                                      the contrlVis field of the record.
  90.                                                      kControlVisible is used the same way to 'turn
  91.                                                      on' the control.}
  92.  
  93.             kCntlActivate        = 0;                { enabled control’s hilite state }
  94.             kCntlDeactivate     = $FF;                { disabled control’s hilite state }
  95.             kCntlOn             = 1;                { control’s value when truned on }
  96.             kCntlOff            = 0;                { control’s value when truned off }
  97.             kSelect             = 1;                { select the control }
  98.             kDeselect            = 0;                { deselect the control }
  99.  
  100.             kScrollbarWidth     = 16;                { kScrollBarWidth can be used in
  101.                                                      calculating values for control
  102.                                                      positioning and sizing.}
  103.             kScrollbarAdjust    = kScrollbarWidth - 1;
  104.  
  105.             kDelayTime            = 8;                { For the delay time when flashing the
  106.                                                      menubar and highlighting a button.
  107.                                                      8/60ths of a second}
  108.  
  109.             kStartPtH            = 2;                { offset from the left of the screen }
  110.             kStartPtV            = 2;                { offset from the top of the screen }
  111.             kStaggerH            = 16;                { staggering amounts for new windows }
  112.             kStaggerV            = 22;
  113.  
  114.             chBackspace         = CHR(8);            { ASCII code for Backspace character }
  115.             chClear             = CHR(27);            { ASCII code for Clear key (aka ESC) }
  116.             chDown                = CHR(31);            { ASCII code for down arrow }
  117.             chEnd                = CHR(4);            { ASCII code for the End key }
  118.             chEnter             = CHR(3);            { ASCII code for Enter character }
  119.             chEscape            = CHR(27);            { ASCII code for Escape (aka Clear) key }
  120.             chFunction            = CHR(16);            { ASCII code for any function key }
  121.             chFwdDelete         = CHR($7F);         { ASCII code for forward delete }
  122.             chHelp                = CHR(5);            { ASCII code for Help key }
  123.             chHome                = CHR(1);            { ASCII code for the Home key }
  124.             chLeft                = CHR(28);            { ASCII code for left arrow }
  125.             chPageDown            = CHR(12);            { ASCII code for Page Down key }
  126.             chPageUp            = CHR(11);            { ASCII code for Page Up key }
  127.             chReturn            = CHR(13);            { ASCII code for Return character }
  128.             chRight             = CHR(29);            { ASCII code for right arrow }
  129.             chSpace             = CHR(32);            { ASCII code for Space character }
  130.             chTab                = CHR(9);            { ASCII code for Tab character }
  131.             chUp                = CHR(30);            { ASCII code for up arrow }
  132.             
  133.             { Define these for gQDVersion }
  134.             kQDOriginal            = 0;                { Original QuickDraw }
  135.             kQD8Bit                = 1;                { 8-bit Color QuickDraw }
  136.             kQD32Bit            = 2;                { 32-bit QuickDraw }
  137.  
  138.         TYPE
  139.  
  140.         { Various handy types for type coercion. For instance, you can take a handle,
  141.           cast it into a RectHandle, dereference it twice, and get a Rect. I.e.,
  142.  
  143.             myRect := RectHandle(someHandle)^^;
  144.  
  145.           Of course, this assumes that you know there is a valid rectangle at that
  146.           location in the block of data referenced by the handle. }
  147.  
  148.         { Some of these are now defined in MPW 3.2 }
  149. {$IFC NOT MPW32}
  150.             IntegerPtr            = ^INTEGER;
  151. {$ENDC}
  152.             IntegerHandle        = ^IntegerPtr;
  153.  
  154. {$IFC NOT MPW32}
  155.             LongIntPtr            = ^LONGINT;
  156. {$ENDC}
  157.             LongIntHandle        = ^LongIntPtr;
  158.  
  159.             BooleanPtr            = ^BOOLEAN;
  160.             BooleanHandle        = ^BooleanPtr;
  161.  
  162.             SignedBytePtr        = ^SignedByte;
  163.             SignedByteHandle    = ^SignedBytePtr;
  164.  
  165.             RectHandle            = ^RectPtr;
  166.  
  167.             WindowPeekPtr        = ^WindowPeek;
  168.  
  169.             { This is the template to the WIND resource. }
  170.  
  171.             WindowTemplate        = RECORD            {template to a WIND resource}
  172.                 boundsRect:         Rect;
  173.                 procID:             INTEGER;
  174.                 visible:            BOOLEAN;
  175.                 filler1:            BOOLEAN;
  176.                 goAwayFlag:         BOOLEAN;
  177.                 filler2:            BOOLEAN;
  178.                 refCon:             LONGINT;
  179.                 title:                Str255;
  180.                 END;
  181.             WindowTPtr            = ^WindowTemplate;
  182.             WindowTHndl         = ^WindowTPtr;
  183.  
  184.             TwoIntsMakesALong    = RECORD            {build a signed LONGINT...}
  185.                 CASE INTEGER OF                     {...from an unsigned INTEGER}
  186.                     1:
  187.                         (long:                 LONGINT);
  188.                     2:
  189.                         (ints:                 ARRAY [0..1] OF INTEGER);
  190.                 END;                                {TwoIntsMakesALong}
  191.  
  192.         VAR
  193.  
  194.         { The following global variables are initialized by StardardInitialization to
  195.             define the environnment.  This used to be a single SysEnvRec, but now,
  196.             all those variables defined in a SysEnvRec can be returned by Gestalt
  197.             (except sysVRefNum; see FindSysFolder).  Note that all the variables
  198.             below will be correctly initialized whether Gestalt is available or not;
  199.             the Gestalt glue handles this. }
  200.  
  201.             gMachineType:        INTEGER;            {which machine this is}
  202.             gSystemVersion:        INTEGER;            {System version number}
  203.             gProcessorType:        INTEGER;            {which CPU this is}
  204.             gHasFPU:            BOOLEAN;            {true if machine has an FPU}
  205.             gQDVersion:            INTEGER;            {major QD version #; 0 for original, 
  206.                                                         1 for color QD, 2 for 32-bit QD}
  207.             gKeyboardType:        INTEGER;            {which type of keyboard is present}
  208.             gAppleTalkVersion:    INTEGER;            {AppleTalk version number}
  209.         
  210.         { These are also handled by Gestalt. gHasPMMU has no corresponding SysEnvRec
  211.             field, but it is handled by the glue, so we include it here for completeness.
  212.             gAUXVersion will be initialized with Gestalt if present, but correctly
  213.             set even if Gestalt is not available}
  214.             gHasPMMU:            BOOLEAN;            {true if machine has a PMMU or equivalent}
  215.             gAUXVersion:        INTEGER;            {major A/UX version number (0 if not present)}
  216.  
  217.         { gHasWaitNextEvent is set to TRUE if the Macintosh we are running on has
  218.           WaitNextEvent implemented. We can use this in our main event loop to
  219.           determine whether to call WaitNextEvent or GetNextEvent. }
  220.  
  221.             gHasWaitNextEvent:    BOOLEAN;            {set up by StandardInitialization}
  222.  
  223.         { gAppResRef is the application’s resource file reference. I need to save
  224.           this since I can open other resource files. The current resource file is
  225.           always gAppResRef unless I momentarily set it to another file to read its
  226.           resources, and then immediately restore it back.}
  227.  
  228.             gAppResRef:         INTEGER;            {set up by StandardInitialization}
  229.  
  230.         { gInBackground is maintained by our osEvent handling routines. Any part of
  231.           the program can check it to find out if it is currently in the background.}
  232.  
  233.             gInBackground:        BOOLEAN;            {maintained by StandardInitialization and
  234.                                                      DoEvent}
  235.  
  236.         { gAppName holds the name of the application that's running. You can use if
  237.           for any purpose you'd like. It is also used by StandardAbout if it can't
  238.           find a string to use for the application name in a resource, so make sure
  239.           you call InitForStandardAbout if you are going to call StandardAbout. If you
  240.           call StandardInitialization, this is done for you. }
  241.  
  242.             gAppName:            Str255;
  243.  
  244.         { gSignature holds the creator signature for the running application. It follows the
  245.           same rules as those for gAppName. }
  246.  
  247.             gSignature:            OSType;
  248.  
  249.         { Initial values of these global variables are set to zero or FALSE by MPW's 
  250.           runtime initialization routines.  If the Utilities initialization routines
  251.           have been properly called, then gUtilitiesInited will be true.  If it is
  252.           not true, then the values of the above global variables are invalid. }
  253.  
  254.             gUtilitiesInited:    BOOLEAN;
  255.  
  256.         FUNCTION CenteredAlert(alertID: INTEGER; relatedWindow:WindowPtr): INTEGER;
  257.         { Given an Alert ID and a related window pointer, this routine will center
  258.           the alert on the same device as the related window.  If the related
  259.           window pointer is nil, then the alert will be centered on the device
  260.           that the alert would normally be placed if Alert was called directly. }
  261.  
  262.         PROCEDURE CenterRectInRect(outerRect: Rect; VAR innerRect: Rect);
  263.         { Given two rectangles, this routine centers the second one within the first. }
  264.  
  265.         FUNCTION CenterWindow(window:WindowPtr; relatedWindow:WindowPtr): Rect;
  266.         { Given a window pointer and a related window pointer, this routine will
  267.           center the window on the same device as the related window.  If the
  268.           related window pointer is nil, then the window will be centered on the
  269.           device that the window already is.
  270.           WARNING: This routine may move or purge memory. }
  271.  
  272.         PROCEDURE CloseAnyWindow(window: WindowPtr);
  273.         { Closes the indicated window.  Does the right thing, taking into account
  274.           that the window may belong to a DA.
  275.           WARNING: An application window is closed via a CloseWindow call.  Use
  276.                        this call when you want to keep the storage for the window
  277.                     record.  (Compare against DisposeAnyWindow.) }
  278.  
  279.         PROCEDURE DisposeAnyWindow(window: WindowPtr);
  280.         { Closes the indicated window.  Does the right thing, taking into account
  281.           that the window may belong to a DA.
  282.           WARNING: An application window is closed via a DisposeWindow call.  Use
  283.                        this call when you want to free up the storage for the window
  284.                     record.  (Compare against CloseAnyWindow.) }
  285.  
  286.         PROCEDURE DeathAlert(errResID: INTEGER; errStringIndex: INTEGER);
  287.         { Display an alert that tells the user an error occurred, then exit the
  288.           program. This routine is used as an ultimate bail-out for serious errors
  289.           that prohibit the continuation of the application. } 
  290.  
  291.         PROCEDURE DeathAlertMessage(errResID, errStringIndex, message: INTEGER);
  292.  
  293.         PROCEDURE ErrorAlert(errResID, errStringIndex: INTEGER);
  294.  
  295.         PROCEDURE ErrorAlertMessage(errResID, errStringIndex, message: INTEGER);
  296.  
  297.         FUNCTION FindSysFolder (VAR foundVRefNum: INTEGER; VAR foundDirID: LongInt): OSErr;
  298.         { FindSysFolder returns the (real) vRefNum, and the DirID of the current
  299.           system folder.  It uses the Folder Manager if present, otherwise 
  300.           it falls back to SysEnvirons.  It returns zero on success, otherwise 
  301.           a standard system error.}
  302.  
  303.         FUNCTION GetAppIndResource(theType: ResType;index: INTEGER; VAR err:OSErr): Handle;
  304.         { GetAppIndResource gets a resource from the application's resource file by index }
  305.         
  306.         FUNCTION GetAppNamedResource(theType: ResType;name: Str255; VAR err:OSErr): Handle;
  307.         { GetAppNamedResource gets a resource from the application's resource file by name }
  308.         
  309.         FUNCTION GetAppResource(theType:ResType; theID:INTEGER; VAR err:OSErr): Handle;
  310.         { GetAppResource gets a resource from the application's resource file by resource ID }
  311.         
  312.         FUNCTION GetAUXVersion: INTEGER;
  313.  
  314.         FUNCTION    GetCenteredDialog(id:INTEGER; storage: Ptr; 
  315.             relWindow, behind:WindowPtr): DialogPtr;
  316.         { Given a dialog ID and a related window pointer, this routine will center
  317.           the dialog on the same device as the related window.  If the related
  318.           window pointer is nil, then the dialog will be centered on the device
  319.           that the dialog would normally be placed if GetNewDialog was called. }
  320.  
  321.         FUNCTION    GetCenteredWindow(id:INTEGER; storage: Ptr; relWindow, behind: WindowPtr;
  322.             inColor:BOOLEAN): WindowPtr;
  323.         { Given a window ID and a related window pointer, this routine will center
  324.           the window on the same device as the related window.  If the related
  325.           window pointer is nil, then the window will be centered on the device
  326.           that the window would normally be placed if GetNewWindow was called. }
  327.  
  328.         FUNCTION GetCheckOrRadio(dlgPtr: DialogPtr; itemNo: integer): BOOLEAN;
  329.  
  330.         FUNCTION GetGestaltResult (gestaltSelector: OSType): LongInt;
  331.         { GetGestaltResult returns the result value from Gestalt for the specified selector.
  332.             If Gestalt returned an error GetGestaltResult returns zero.  Use of this function
  333.             is only cool if we don't care whether Gestalt returned an error.  In many cases
  334.             you may need to know the exact Gestalt error code so then this routine would be
  335.             inappropriate.}
  336.         
  337.         FUNCTION GetGlobalMouse: Point;
  338.         { Returns the location of the mouse in local coordinates. It does this by
  339.           calling OSEventAvail. }
  340.  
  341.         FUNCTION GetGlobalTopLeft(window: WindowPtr): Point;
  342.         { Given a window, this will return the top left point of the window’s port in
  343.           global coordinates. Something this doesn’t include, is the window’s drag
  344.           region (or title bar). This returns the top left point of the window’s
  345.           content area only. }
  346.  
  347.         FUNCTION GetKFreeSpace(vRefNum: INTEGER): LONGINT;
  348.  
  349.         FUNCTION GetMainScreenRect: Rect;
  350.  
  351.         FUNCTION GetRectDevice(globalRect: Rect): GDHandle;
  352.         { Find the greatest overlap device for the given global rectangle. }
  353.  
  354.         FUNCTION GetRectDeviceRect(globalRect: Rect): Rect;
  355.         { Find the rect of the greatest overlap device for the given global rect. }
  356.  
  357.         FUNCTION    GetSomeKindOfWindow(FUNCTION whatKind(window, relWindow:WindowPtr):Rect; 
  358.             windID:INTEGER; storage: Ptr; relWindow, behind:WindowPtr; inColor:BOOLEAN):WindowPtr;
  359.         { Given a window positioning procedure pointer, a window ID and a window
  360.           pointer the window relates to, this function open a new window by either
  361.           a NewCWindow or a NewWindow call, depending on the value of inColor.  The
  362.           window will be opened invisible, independent of what the resource says.
  363.           Once the window is opened successfully, the positioning procedure is
  364.           called.  The positioning procedure is passed a pointer to the just-opened
  365.           invisible window and a pointer to the related window.  It is up to the
  366.           positioning procedure to move the invisible window to the correct location
  367.           on the correct device.  Once the positioning procedure returns, the window
  368.           will be made visible if so indicated by the resource. }
  369.  
  370.         FUNCTION    GetStaggeredWindow(id:INTEGER; storage: Ptr; 
  371.             relWindow,behind:WindowPtr; inColor:BOOLEAN):WindowPtr;
  372.         { Given a window ID and a window pointer the window relates to, this function
  373.           will stagger the window’s rectangle before showing it on the proper screen.
  374.           This follows the Apple Human Interface Guidelines for where to place a
  375.           staggered window on the screen.  If the window is not closely associated
  376.           with another window, pass a nil for the window pointer of the related
  377.           window.  If you pass a nil, the window is simply displayed where the
  378.           resource would indicate. }
  379.  
  380.         FUNCTION GetTrapType(theTrap: INTEGER): TrapType;
  381.         { Returns the type (OSType or ToolType) of the trap. It does this by checking
  382.           the bits of the trap word. }
  383.  
  384.         FUNCTION GetWindowContentRect(window:WindowPtr):Rect;
  385.         { Given a window pointer, return the global rectangle that encloses the
  386.           content area of the window. }
  387.  
  388.         FUNCTION GetWindowCount(includeDAs,includeInvisibles:BOOLEAN):INTEGER;
  389.         { This procedure counts the number of windows in the application plane.  You
  390.           have the choices of also including DAs and invisible windows in this count. }
  391.  
  392.         FUNCTION GetWindowDevice(window:WindowPtr):GDHandle;
  393.         { Find the greatest overlap device for the given window. }
  394.  
  395.         FUNCTION GetWindowDeviceRect(window:WindowPtr):Rect;
  396.         { Given a window pointer, find the device that contains most of the window
  397.           and return the device's bounding rectangle. }
  398.  
  399.         FUNCTION GetWindowDeviceRectNMB(window:WindowPtr):Rect;
  400.         { Given a window pointer, find the device that contains most of the window
  401.           and return the device's bounding rectangle.  If this device is the main
  402.           device, then remove the menubar area from the rectangle. }
  403.  
  404.         FUNCTION GetWindowStructureRect(window:WindowPtr):Rect;
  405.         { This procedure is used to get the rectangle that surrounds the entire
  406.           structure of a window.  This is true whether or not the window is visible.
  407.           If the window is visible, then it is a simple matter of using the bounding
  408.           rectangle of the structure region.  If the window is invisible, then the
  409.           strucRgn is not correct.  To make it correct, then window has to be moved
  410.           way off the screen and then made visible.  This generates a valid strucRgn,
  411.           although it is valid for the position that is way off the screen.  It still
  412.           needs to be offset back into the original position.  Once the bounding
  413.           rectangle for the strucRgn is obtained, the window can then be hidden again
  414.           and moved back to its correct location.  Note that ShowHide is used,
  415.           instead of ShowWindow and HideWindow.  HideWindow can change the plane of
  416.           the window.  Also, ShowHide does not affect the hiliting of windows. }
  417.   
  418.         PROCEDURE GlobalToLocalRect(VAR aRect: Rect);
  419.  
  420.         PROCEDURE InitToolBox;
  421.  
  422.         PROCEDURE InitUtilities;
  423.         { This sets up some global variables for use by the utilities package.  If you call
  424.            StandardInitialization, you don't need to call this, as it will do it for you. } 
  425.  
  426.         FUNCTION IsAppWindow(window: WindowPtr): BOOLEAN;
  427.         { Returns TRUE if the windowKind of the window is greater than or equal to
  428.           userKind. If it is less, or the window is NIL, then return FALSE. }
  429.  
  430.         FUNCTION IsDAWindow(window: WindowPtr): BOOLEAN;
  431.         { Returns TRUE if the windowKind of the window is less than zero. If not, or
  432.           the window is NIL, then return FALSE. }
  433.  
  434.         PROCEDURE LocalToGlobalRect(VAR aRect: Rect);
  435.  
  436.         FUNCTION LockHandleHigh(theHandle: UNIV Handle): SignedByte;
  437.         { Does a MoveHHi on the handle and then locks it.  Also, the original state
  438.           of the handle is returned, so you can keep it and set the handle back to it's
  439.           original state with a HSetState call. }
  440.  
  441.         FUNCTION NumToolboxTraps: INTEGER;
  442.         { Determines the size of the Tool trap table. It does this by sampling a
  443.           couple of trap locations and seeing which, if any are Unimplemented. }
  444.  
  445.         PROCEDURE OutlineControl(button: UNIV ControlHandle);
  446.         
  447.         PROCEDURE OutlineDialogItem(dlgPtr: DialogPtr; item: integer);
  448.  
  449.         PROCEDURE PositionRectInRect(outerRect: Rect; VAR innerRect: Rect; horzRatio,vertRatio: Fixed);
  450.         {  Given two rectangles, this routine positions the second within the first one
  451.            so that the it maintains the spacing specified the the horzRatio and vertRatio
  452.            parameters. In other words, to center an inner rectangle hoizontally, but
  453.            have its center be 1/3 from the top of the outer rectangle, call this
  454.            routine with horzRatio = FixRatio (1, 2), vertRatio = FixRatio (1, 3). }
  455.  
  456.         PROCEDURE PullApplicationToFront;
  457.  
  458.         PROCEDURE SelectButton(button: UNIV ControlHandle);
  459.         {  Given the button control handle, this will cause the button to look as if it
  460.            has been clicked in. This is nice to do for the user if they type return or
  461.            enter to select the default item. }
  462.  
  463.         PROCEDURE SetCheckOrRadioButton(dlgPtr: DialogPtr; itemNo: INTEGER; state: INTEGER);
  464.  
  465.         FUNCTION StaggerWindow(window,relatedWindow:WindowPtr):Rect;
  466.         { This algorithm for staggering windows does quite a good job.  It also is
  467.           quite gnarly.  Here's the deal:
  468.           There are pre-designated positions that we will try when positioning a
  469.           window.  These slots will be tried from the upper-left corner towards the
  470.           lower-right corner.  If there are other windows in that slot, then we will
  471.           consider that slot taken, and proceed to the next slot.  A slot is
  472.           determined to be taken by checking a point with a slop area.  This slop
  473.           area is diamond-shaped, not simply rectangular.  If there is no other
  474.           visible window with an upper-left corner within the slopt diamond, then
  475.           we are allowed to position our window there.
  476.           The above rule holds true unless this forces the window to be partly
  477.           off the screen.  If the window ends up partly off the screen, then we give
  478.           up and just put it in the first slot. }
  479.  
  480.         PROCEDURE StandardAbout(appNameStringID: INTEGER);
  481.         { Shows a standard about box with the name of the application, its version
  482.           number, a copyright notice, and DTS credits. Most of this information is
  483.           taking from a standard DITL and the application’s 'vers' resource. The name
  484.           of the application is taken either from the 'STR ' resource passed in to
  485.           this routine, or from GetAppParms if that resource doesn’t exist, or you
  486.           pass in -1. }
  487.  
  488.         PROCEDURE StandardInitialization(callsToMoreMasters: INTEGER);
  489.         { Initializes “gInBackGround” to FALSE. Makes the following InitXXX calls:
  490.           InitGraf, InitFonts, InitWindows, InitMenus, TEInit, InitDialogs,
  491.           InitCursor. Brings application to front with 3 EventAvail calls. 
  492.           Initializes some variables using Gestalt. Calls TrapExists to initialize
  493.           “gHasWaitNextEvent”. }
  494.  
  495.         PROCEDURE StandardMenuSetup(MBARID, AppleMenuID: INTEGER);
  496.         { Installs and draws the menus indicated by 'MBAR'(MBARID). Adds DA’s to the
  497.           menu indicated by AppleMenuID by calling AddResMenu. If the menuBar cannot
  498.           be created, the alert specified by rDeathAlert is displayed. }
  499.  
  500.         PROCEDURE ToggleCheck(dlgPtr: DialogPtr; chkItem: integer);
  501.  
  502.         FUNCTION TrapExists(theTrap: INTEGER): BOOLEAN;
  503.         { Returns TRUE if the trap exists (i.e., it’s callable without getting DS
  504.           error 12) }
  505.  
  506.         PROCEDURE ZoomToWindowDevice(window:WindowPtr; maxWidth,maxHeight,zoomDir:INTEGER; front:BOOLEAN);
  507.  
  508.     IMPLEMENTATION
  509.  
  510. {$I Utilities.inc1.p}
  511.  
  512. END.
  513.